<div class="col-xs-12 em-pd-l5 em-h100" id="table-div">
	<div class="em-pack">
		<div class="em-pack-title em-pd-0-20 aui-flex-col aui-flex-middle">
			<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
			<span class="aui-flex-auto">设备列表</span>
			<form class="form-inline" onsubmit="return false">
				<label for="eqptKey">设备编号</label>
				<input type="text" id="eqptKey" class="form-control" placeholder="请输入设备编号" />
				<label for="eqptStatus">运行状态</label>
				<select class="form-control" id="eqptStatus">
					<option value="">所有</option>
					<option value="正常">正常</option>
					<option value="维修">维修</option>
					<option value="闲置">闲置</option>
				</select>
				<label for="eqptStatus">是否在线</label>
				<select class="form-control" id="isOnline">
					<option value="-1">所有</option>
					<option value="1">在线</option>
					<option value="2">不在线</option>
				</select>
				<button type="button" class="btn btn-xs btn-info"
						onclick="showEqptList()">查询</button>
			</form>
		</div>
		<div class="em-pack-box" id="eqptDataGrid"></div>
	</div>
</div>
<script type="text/html" id="eqpt_list_tpl">
<table class="table table-hover table-bordered" style="table-layout: fixed">
	<tr>
		<th width="15%" class="aui-ellipsis-1" title="类型/型号">类型/型号</th>
		<th width="10%" class="aui-ellipsis-1" title="生产厂家">生产厂家</th>
		<th width="15%" class="aui-ellipsis-1" title="出厂编号/自定义编号">出厂编号/自定义编号</th>
		<th width="10%" class="aui-ellipsis-1" title="所属组织">所属组织</th>
		<th width="15%" class="aui-ellipsis-1" title="终端编号">终端编号</th>
		<th width="5%" class="aui-ellipsis-1" title="运行状态">运行状态</th>
		<th width="10%" class="aui-ellipsis-1" title="是否在线">是否在线</th>
		<th width="20%" class="aui-ellipsis-1">操作</th>
	</tr>
{{each list as it i}}
	<tr>
		<td class="aui-ellipsis-1" title="{{it.TypeName}}/{{it.Model}}">{{it.TypeName}}-{{it.Model}}</td>
		<td class="aui-ellipsis-1" title="{{it.Manufacturer}}">{{it.Manufacturer}}</td>
		<td class="aui-ellipsis-1" title="{{it.FactoryCode}}/{{it.EqptCode}}">{{it.FactoryCode}}/{{it.EqptCode}}</td>
		<td class="aui-ellipsis-1" title="{{it.OrgName}}">{{it.OrgName}}</td>
		<td class="aui-ellipsis-1" title="{{it.TermCode}}">{{it.TermCode}}</td>
		<td class="aui-ellipsis-1" title="{{it.Status}}">{{it.Status}}</td>
		<td class="aui-ellipsis-1" title="{{it.isOnline}}">{{it.isOnline}}</td>
		<td class="text-left">
			<button  type="button"  class="btn btn-xs btn-info" {{if it.TermCode_L==null && it.TermCode_R==null}}disabled{{/if}}
					 onclick="showEqptGK('{{it.EqptId}}','{{it.EqptCode}}','{{it.TypeName}}','{{it.TermCode}}')">查看工况</button>
			<button type="button" class="btn btn-xs btn-info" onclick="openHistoryList('{{it.EqptId}}')">历史故障</button>
			{{if it.lock==0}}
			<button type="button" class="btn btn-xs btn-info"
					onclick="eqptLock('{{it.EqptId}}','{{it.EqptCode}}','{{it.TypeName}}','{{it.TermCode}}')">锁机</button>
			{{else}}
			<button type="button" class="btn btn-xs btn-info"
					onclick="eqptUnLock('{{it.EqptId}}','{{it.EqptCode}}','{{it.TypeName}}','{{it.TermCode}}')">解锁</button>
			{{/if}}
		</td>
	</tr>
{{/each}}
</table>
</script>
<script type="text/javascript">
	var BindingTermDialog = {
		popWidth : 350,
		src : "../eqpt/term_select_dialog.html"
	};
	showEqptList()
	//查看PLC工况页面
	function showEqptGK(eqptId,eqptCode,typeName,termCode){
		em.EqptId = eqptId;
		em.EqptCode = eqptCode;
		em.TermCode = termCode;
		em.EqptType = typeName;
		_setStorage('eqptId',eqptId);
		_setStorage('eqptCode',eqptCode);
		location.href='../tdm/GBM_realWorking.html';
	}
	//显示设备列表
	function showEqptList() {
		$("#eqptDataGrid").getGrid({
			eqptkey:$("#eqptKey").val().trim(),
			status:$("#eqptStatus").val(),
			type:$("#eqptType").val(),
			isOnline:$('#isOnline').val(),
			sql:"eqpt.getEqptListByOrg",
			tpl:"eqpt_list_tpl"
		})
	}
	//查看设备历史故障列表
	function openHistoryList(eqptId){
		location.href='../tdm/history_work.html';
	}
	function getEqptById(eqptId,eqptCode,typeName,termCode) {
		em.EqptId = eqptId;
		em.EqptCode = eqptCode;
		em.TermCode = termCode;
		em.EqptType = typeName;
		FullDialog("../eqpt/eqpt_detail.html");
	}
	function eqptLock(eqptId,eqptCode,typeName,termCode) {
		em.EqptId = eqptId;
		em.EqptCode = eqptCode;
		em.TermCode = termCode;
		em.EqptType = typeName;
		if(confirm('是否确定锁机?')){
		callSvr('eqpt/EqptLock',{'eqptId':em.EqptId},function(data){
			!data.err ?(toastr.success('锁机成功')):(toastr.error('锁机失败'));
			showEqptList();
		})
		}
	}
	function eqptUnLock(eqptId,eqptCode,typeName,termCode) {
		em.EqptId = eqptId;
		em.EqptCode = eqptCode;
		em.TermCode = termCode;
		em.EqptType = typeName;
		if(confirm('是否解锁')){
		callSvr('eqpt/EqptLockOut',{'eqptId':em.EqptId},function(data){
			!data.err ?(toastr.success('解锁成功')):(toastr.error('解锁失败'));
			showEqptList()
		})
		}
	}
</script>